# frozen_string_literal: true

class CreateRuleOutputs < ActiveRecord::Migration[6.0]
  def change
    create_table :rule_outputs do |t|
      t.integer :general_rule_id, null: false,  limit: 8
      t.integer :ordinal,         null: false,  limit: 4
      t.string  :name,            null: false,  limit: 64
      t.string  :type,            null: false,  limit: 64
      t.string  :value,           null: true,   limit: 255
      t.timestamps                null: false
    end

    add_index :rule_outputs, %i[name general_rule_id], unique: true
    add_index :rule_outputs, %i[ordinal general_rule_id], unique: true
    add_foreign_key :rule_outputs, :rule_entities, column: :general_rule_id
  end
end
